package com.mocha.nezha.dmo;

import com.mocha.nezha.nezha.PoleVertex;
import lombok.*;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author songkui
 * @since 2024/3/21 10:38
 */
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode(of = {"objectId"})
@ToString
public class VehicleBO {

    private String parkCode; //园区编号

    private String objectId; //汽车编码
    private String vehicleNo; // 汽车号牌


//    private PoleVertex lastPole; // 上一个杆子
    private PoleVertex currentPole; // 现在处于杆子
    private BigDecimal time = new BigDecimal("0");
    private int pointCount; //总共跑了多少坐标点位

    public VehicleBO(String parkCode, String objectId, String vehicleNo){
        this.parkCode = parkCode;
        this.objectId = objectId;
        this.vehicleNo = vehicleNo;
    }

    //TODO 这个值 可以根据 距离 和初始速度 计算
    public double buildTime(double t){
        if (pointCount == 0){
            ++ pointCount;
            return 0;
        }
        ++ pointCount;

        time = time.add(new BigDecimal(String.valueOf(t)));
        return time.setScale(2, RoundingMode.HALF_UP).doubleValue();
    }


}
